home *** CD-ROM | disk | FTP | other *** search
AMOS Source Code | 1996-01-17 | 3.0 KB | 111 lines |
- ' *************************************
- ' * *
- ' * AMCAF Iff To Raw Converter V1.0 *
- ' * Written by Chris Hodges *
- ' * *
- ' *************************************
- '
- ' Using this program you can convert an (aga) iff picture into raw format,
- ' which is required for displaying it via the ShowAGAPic procedures.
- '
- Screen Open 0,640,256,2,$8000
- Curs Off : Flash Off : Paper 0 : Pen 1 : Cls
- F$=Fsel$("","","Select an iff file to convert","")
- If F$="" Then End
- Print "Loading "+F$+"..." : Print
- Gosub CHUNKDECODE
- Print "Conversion successful."
- F$=Fsel$( Extension_8_03E0(F$), Extension_8_02F0(F$)-".iff","Select the base name","of the file to save")
- If F$="" Then End
- Print "Saving..."
- Extension_8_0472 F$+".col",8
- Extension_8_0472 F$+".raw",10
- Erase All
- End
- CHUNKDECODE:
- Extension_8_0456 F$,9
- ST=Start(9) : LE=Length(9)
- Reserve As Work 8,1024
- CMAP=Start(8)
- If Leek(ST)<> Extension_8_0998("FORM") Then Print "Not an IFF-File!" : Stop
- If Leek(ST+8)<> Extension_8_0998("ILBM") Then Print "Not an ILBM-File!" : Stop
- If Leek(ST+4)+8<>LE Then Print "Mangeled IFF-FORM!" : Stop
- AD=ST+12
- Repeat
- LCH=Leek(AD+4)
- CHNK=Leek(AD)
- If CHNK= Extension_8_0998("BMHD")
- Print "Found BMHD-Chunk."
- SX=Deek(AD+8)
- SY=Deek(AD+10)
- Print "Width :";SX
- Print "Height:";SY
- PL=Peek(AD+16)
- If PL<>8
- Print "Warning! This picture only uses"; Extension_8_04F8(PL);" colours!"
- Else
- Print "Planes:";PL
- End If
- PK=Peek(AD+18)
- Print "Packed: "; Extension_8_16A4("no|rle",PK)
- GX=Deek(AD+24)
- GY=Deek(AD+26)
- Reserve As Work 10,SX*SY
- BMP=Start(10) : BMPSIZE=(SX/8)*SY
- Reserve As Work 11,4096
- TST=Start(11)
- End If
- If CHNK= Extension_8_0998("CMAP")
- Print "Found colormap..."
- For A=0 To(LCH/3)-1
- Poke CMAP+A*4+1,Peek(AD+8+A*3)
- Poke CMAP+A*4+2,Peek(AD+9+A*3)
- Poke CMAP+A*4+3,Peek(AD+10+A*3)
- Next
- End If
- If CHNK= Extension_8_0998("BODY")
- Print "Found BODY... please wait while converting."
- BMPOF=BMP : X=0 : P=0
- If PK
- POS=AD+8
- Repeat
- CON=Peek(POS) : Inc POS
- If CON<128
- For A=0 To CON
- B=Peek(POS) : Gosub BYTEPUT
- Inc POS
- Next
- End If
- If CON>128
- B=Peek(POS) : Inc POS
- For A=0 To 256-CON
- Gosub BYTEPUT
- Next
- End If
- Until POS=>AD+8+LCH
- If BMPOF<>BMP+BMPSIZE : FAIL=1 : End If
- Else
- For A=0 To LCH-1
- B=Peek(AD+8+A)
- Gosub BYTEPUT
- Next
- End If
- End If
- If LCH and 1 Then Inc AD
- Add AD,LCH+8
- Until AD=>ST+LE
- If FAIL Then Print "Error during conversion! Memory could be corrupt!" : Stop
- Return
- End
- BYTEPUT:
- Poke BMPOF+P*BMPSIZE,B
- Inc BMPOF : Add X,8
- If(X and $FFF8)=>SX
- Inc P : X=0
- If P=>PL
- P=0
- Else
- Add BMPOF,-SX/8
- End If
- End If
- Return